function e(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

function t(e, t, i) {
    return t in e ? Object.defineProperty(e, t, {
        value: i,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = i, e;
}

Object.defineProperty(exports, "__esModule", {
    value: !0
});

var i = e(require("../../../utils/util")), a = e(require("../../../utils/config"));

exports.default = {
    addTo: function(e, s) {
        e.$addListener("quicklink.update", function(i, a) {
            e.data.$$editor.sections.forEach(function(s, d) {
                if ("quicklink" === s.type) {
                    var n = s.data, r = n.findIndex(function(e) {
                        return e.linkid === i.linkid;
                    });
                    -1 !== r && (0 === a ? e.setData(t({}, "$$editor.sections[" + d + "].data[" + r + "]", i)) : (n.splice(r, r + 1), 
                    e.setData(t({}, "$$editor.sections[" + d + "].data", n))));
                }
            });
        }), Object.assign(e, {
            $$quicklinkEdit: function(e) {
                this.$route("/pages/editor/quicklink/quick-link/quick-link?sid=" + s.sid + "&index=" + e + "&mode=0");
            },
            $$updateQCLayout: function(i) {
                wx.showActionSheet({
                    itemList: [ "图形按钮", "方块矩阵", "文字浮层" ],
                    success: function(a) {
                        var s = a.tapIndex;
                        e.setData(t({}, "$$editor.sections[" + i + "].layoutid", s + 1));
                    }
                });
            },
            $$gotoQuicklink: function(t) {
                var s = getCurrentPages();
                if ("view" === s[s.length - 1].data.mode) {
                    var d = t.currentTarget.dataset.quicklink, n = d.params;
                    4 == +n.modid && n.cid ? (n.id = n.cid, delete n.cid) : 5 == +n.modid && (n.caseid = n.cid);
                    var r = i.default.createModelUrl(a.default.model, Object.assign({}, n, {
                        sid: d.sid
                    })), o = 1 == +n.id, c = e.data.sidebar.site, u = c.address, l = c.addresslat, p = c.addresslng, m = e.data.site, k = m.tel, f = m.sid, g = m.app, $ = m.mchid;
                    switch (d.type) {
                      case "nav":
                      case "page":
                        this.$route(r, o ? "redirect" : "go");
                        break;

                      case "mobile":
                        wx.makePhoneCall({
                            phoneNumber: k || ""
                        });
                        break;

                      case "map":
                        wx.openLocation({
                            address: u,
                            latitude: l,
                            longitude: p
                        });
                        break;

                      case "members":
                        this.$route("/pages/profile-entry/members/members?sid=" + f);
                        break;

                      case "cart":
                        this.$route("/pages/common/shopping-cart/shopping-cart?origin=tab&sid=" + f + "&app=" + g + "&mchid=" + $);
                        break;

                      case "payment":
                        this.$route("/pages/common/payment/payment?sid=" + f);
                    }
                }
            }
        });
    }
};